<template>
  <fieldset>
    <legend>冲冲冲</legend>
    <h1>购物车Cart</h1>
    <ul>
      <li v-for="item in cartData" :key="item.id">
        <b>商品: {{ item.title }}</b>
        ————
        <b>价格: {{ item.price }}</b>
        ————
        <b>数量： {{ item.count }}</b>
        <button @click="rmCart(item)">移出购物车</button>
      </li>
    </ul>
    <h1>总价: {{ total }}</h1>
  </fieldset>
</template>

<script>
import { mapState, mapActions, mapGetters } from "vuex";

export default {
  computed: {
    ...mapState("carts", ["cartData"]),
    ...mapGetters("carts", ["total"]),
  },
  methods: {
    ...mapActions("carts", ["RM_CART"]),
    rmCart(item) {
      this.RM_CART(item);
    },
  },
};
</script>

<style></style>
